全部文档

4.1物模型属性

为MQTT、HTTP协议产品和云网关设备提供属性的增删改查功能。

4.1.1根据功能ID查询功能

功能描述:根据产品ID和该产品下的功能ID查询产品功能, 返回产品功能的详细信息。

GET  /api/v1/products/{productId}/properties/{id}

Path:

Name Type Description
productId int 产品ID
id int 属性ID

cURL example:

curl --location --request GET '{{address}} /api/v1/products/{productId}/properties/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response data:

Name Type Description
id int 功能ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W)
type int 数据类型,具体值参考公共能力type类型码表。
unit string 属性单位
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
productId int 产品ID
special struct 对部分数据类型的补充说明
userId string 用户ID
nodeName string 节点名称
required bool 是否必选
kind int 功能分类(1:标准/2:自定义)
class int 功能种类 (1:属性/2:事件)

special的子对象结构体:

Name Type Description
length int string类型的字符串长度,1~2048
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127)

enumArray的子对象结构体:

Name Type Description
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127)
describe string 值对应的说明

Response example:

{
    "data": {
        "id": 9422,
        "userId": null,
        "productId": 103618,
        "name": "test",
        "nodeName": "",
        "identifier": "test",
        "accessMode": 1,
        "type": 1,
        "unit": "",
        "minimum": 0,
        "maximum": 0,
        "minString": null,
        "maxString": null,
        "special": {
            "length": 5,
            "step": null,
            "enumArray": null
        },
        "required": false,
        "kind": 2,
        "class": 1
    },
    "success": true,
    "code": 0,
    "msg": null
}

4.1.2根据产品ID查询所有功能

功能描述:查询指定产品下的功能,返回产品功能列表。

GET  /api/v1/products/{productId}/properties

Path:

Name Type Description
productId int 产品ID

cURL example:

curl --location --request GET '{{address}} /api/v1/products/{productId}/properties?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response data:

Name Type Description
id int 功能ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W)
type int 数据类型,具体值参考公共能力type类型码表。
unit string 属性单位
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
special struct 对部分数据类型的补充说明
productId int 产品ID
userId string 用户ID
nodeName string 节点名称
required bool 是否必选
kind int 功能分类(1:标准/2:自定义)
class int 功能种类 (1:属性/2:事件)

special的子对象结构体:

Name Type Description
length int string类型的字符串长度,1~2048
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127)

enumArray的子对象结构体:

Name Type Description
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127)
describe string 值对应的说明

Response example:

{
    "data": [
        {
            "id": 9422,
            "userId": null,
            "productId": 103618,
            "name": "test",
            "nodeName": "",
            "identifier": "test",
            "accessMode": 1,
            "type": 1,
            "unit": "",
            "minimum": 0,
            "maximum": 0,
            "minString": "0",
            "maxString": "0",
            "special": {
                "length": 5,
                "step": null,
                "enumArray": null
            },
            "required": false,
            "kind": 2,
            "class": 1
        }
    ],
    "success": true,
    "code": 0,
    "msg": null
}

4.1.3新增物模板草稿

功能描述:指定产品,为该产品添加物模板草稿,用于读写产品属性值。返回物模板草稿的ID。

POST  /api/v1/products/{productId}/properties/draft

Path:

Name Type Description Required
productId string 产品ID Yes

Body:

Name Type Description Required
name string 功能名称 Yes
identifier string 属性名称(该产品下唯一) Yes
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W) Yes
type int 数据类型,具体值参考公共能力type类型码表。 Yes
unit string 属性单位 No
minimum number 参数最小值(数值类型特有) No,type为数值类型必填
maximum number 参数最大值(数值类型特有) No,type为数值类型必填
nodeName string 节点名称 No
special struct 对部分数据类型的补充说明 No(string/float32/float64/boolean/enum/bytes时必传)

special的子对象结构体:

Name Type Description Required
length int string/bytes类型的字符串长度,1~2048 No(string/bytes类型时必传)
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点 No(数字类型时必传)
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127) No(boolean或enum类型时必传)

enumArray的子对象结构体:

Name Type Description Required
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127) Yes
describe string 值对应的说明 Yes

Body example:

{
    "name":"cmd_api_wendu02",
    "identifier":"prop_api_wendu02",
    "accessMode":1,
    "type":6,
    "unit":"t",
    "minimum":10.1,
    "maximum":20.2,
    "class":1,
    "minString": null,
    "maxString": null,
    "nodeName": null,
    "special":{
        "step":10.1,
    }
}

cURL example:

curl --location --request POST '{{address}}/api/v1/products/{productId}/properties/draft?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
                "name":"cmd_api_wendu02",
                "identifier":"prop_api_wendu02",
                "accessMode":1,
                "type":6,
                "unit":"t",
                "minimum":10.1,
                "maximum":20.2,
                "class":1,
                "minString": null,
                "maxString": null,
                "nodeName": null,
                "special":{
                    "step":10.1,
                }
            }'

Response data:

Name Type Description
id int 物模板草稿ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W)
type int 数据类型,具体值参考公共能力type类型码表。
unit string 属性单位
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
productId int 产品ID
userId string 用户ID
nodeName string 节点名称

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": {
    "id": 23,
    "name": "cmd_api_wendu02",
    "identifier": "prop_api_wendu02",
    "accessMode": 1,
    "type": 7,
    "unit": "t",
    "minimum": 10,
    "maximum": 20,
    "minString": null,
    "maxString": null,
    "productId": 100152,
    "userId": "a881f626c8ec42ceb4c597a3ce7f0bbe",
    "nodeName": null
  }
}

4.1.4删除物模板草稿

功能描述:删除指定产品下的某一物模板草稿。

DELETE  /api/v1/products/{productId}/properties/draft/{id}

Path:

Name Type Description
productId int 产品ID
id int 物模板草稿ID

cURL example:

curl --location --request DELETE '{{address}} /api/v1/products/{productId}/properties/draft/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": 1
}

4.1.5更新物模板草稿

功能描述:更新指定产品下的某一物模板草稿。

PUT  /api/v1/products/{productId}/properties/draft/{id}

Path:

Name Type Description
productId int 产品ID
id int 属性ID

Body:

Name Type Description Required
name string 功能名称 No
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W) No
unit string 属性单位 No
minimum number 参数最小值(Integer,Long, Float, Double) No
maximum number 参数最大值(Integer,Long, Float, Double) No
special strut 对部分数据类型的补充说明 No

special的子对象结构体:

Name Type Description Required
length int string/bytes类型的字符串长度,1~2048 No(string/bytes类型时必传)
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127) No(boolean或enum类型时必传)

enumArray的子对象结构体:

Name Type Description Required
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127) Yes
describe string 值对应的说明 Yes

Body example:

{
    "name":"cmd_api_wendu02",
    "identifier":"prop_api_wendu02",
    "accessMode":1,
    "type":6,
    "unit":"t",
    "minimum":10.1,
    "maximum":20.2,
    "class":1,
    "minString": null,
    "maxString": null,
    "nodeName": null,
    "special":{
        "step":10.1,
    }
}

cURL example:

curl --location --request PUT '{{address}} /api/v1/products/{productId}/properties/draft/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}' \
--header 'Content-Type: application/json' \
--data-raw '{
                "name":"cmd_api_wendu02",
                "identifier":"prop_api_wendu02",
                "accessMode":1,
                "type":6,
                "unit":"t",
                "minimum":10.1,
                "maximum":20.2,
                "class":1,
                "minString": null,
                "maxString": null,
                "nodeName": null,
                "special":{
                    "step":10.1,
                }
            }'

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": 1
}

4.1.6根据功能ID查询物模板草稿

功能描述:根据产品ID和该产品下的功能ID查询物模板草稿, 返回物模板草稿的详细信息。

GET  /api/v1/products/{productId}/properties/draft/{id}

Path:

Name Type Description
productId int 产品ID
id int 物模板草稿ID

cURL example:

curl --location --request GET '{{address}} /api/v1/products/{productId}/properties/draft/{id}?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response data:

Name Type Description
id int 物模板草稿ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W)
type int 数据类型,具体值参考公共能力type类型码表。
unit string 属性单位
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
productId int 产品ID
special struct 对部分数据类型的补充说明
userId string 用户ID
nodeName string 节点名称
required bool 是否必选
kind int 功能分类(1:标准/2:自定义)
class int 功能种类 (1:属性/2:事件)

special的子对象结构体:

Name Type Description
length int string类型的字符串长度,1~2048
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127)

enumArray的子对象结构体:

Name Type Description
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127)
describe string 值对应的说明

Response example:

{
    "data": {
        "id": 9422,
        "userId": null,
        "productId": 103618,
        "name": "test",
        "nodeName": "",
        "identifier": "test",
        "accessMode": 1,
        "type": 1,
        "unit": "",
        "minimum": 0,
        "maximum": 0,
        "minString": null,
        "maxString": null,
        "special": {
            "length": 5,
            "step": null,
            "enumArray": null
        },
        "required": false,
        "kind": 2,
        "class": 1
    },
    "success": true,
    "code": 0,
    "msg": null
}

4.1.7根据产品ID查询所有物模板草稿

功能描述:查询指定产品下的功能,返回产品物模板草稿列表。

GET  /api/v1/products/{productId}/properties/draft

Path:

Name Type Description
productId int 产品ID

cURL example:

curl --location --request GET '{{address}} /api/v1/products/{productId}/properties/draft?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response data:

Name Type Description
id int 物模板草稿ID
name string 功能名称
identifier string 属性名称(该产品下唯一)
accessMode int 属性读写类型,只读(1:R),读写(2:RW),只写(3:W)
type int 数据类型,具体值参考公共能力type类型码表。
unit string 属性单位
minimum number 参数最小值(数值类型特有)
maximum number 参数最大值(数值类型特有)
minString string 参数最小值(数值类型特有)
maxString string 参数最大值(数值类型特有)
special struct 对部分数据类型的补充说明
productId int 产品ID
userId string 用户ID
nodeName string 节点名称
required bool 是否必选
kind int 功能分类(1:标准/2:自定义)
class int 功能种类 (1:属性/2:事件)

special的子对象结构体:

Name Type Description
length int string类型的字符串长度,1~2048
step double 步长, 设备上传数据间隔, 整型/浮点型类型才有, 分别对应整型、浮点
enumArray struct[] 枚举或布尔类型的相关信息的数组(布尔类型时元素的key有且仅有0/1,枚举类型时元素的个数不超过20个,key范围0~127)

enumArray的子对象结构体:

Name Type Description
key int 枚举或布尔类型的值(布尔类型时key有且仅有0/1,枚举类型时key范围0~127)
describe string 值对应的说明

Response example:

{
    "data": [
        {
            "id": 9422,
            "userId": null,
            "productId": 103618,
            "name": "test",
            "nodeName": "",
            "identifier": "test",
            "accessMode": 1,
            "type": 1,
            "unit": "",
            "minimum": 0,
            "maximum": 0,
            "minString": "0",
            "maxString": "0",
            "special": {
                "length": 5,
                "step": null,
                "enumArray": null
            },
            "required": false,
            "kind": 2,
            "class": 1
        }
    ],
    "success": true,
    "code": 0,
    "msg": null
}

4.1.8发布物模板草稿

功能描述:发布指定产品下的所有物模板草稿。

POST  /api/v1/products/{productId}/properties/draft/publish

Path:

Name Type Description
productId int 产品ID

cURL example:

curl --location --request POST '{{address}} /api/v1/products/{productId}/properties/draft/publish?accessKeyId={accessKeyId}&signatureNonce={signatureNonce}&signature={signature}' \
--header 'projectId: {projectId}'

Response example:

{
  "success": true,
  "code": 0,
  "msg": "",
  "data": null
}

results matching ""

    No results matching ""